import { defineStore } from "pinia";

export const useBirdStore = defineStore("bird", () => {

    const bird = ref({
        id: 0,
        createdAt: '',
        updatedAt: '',
        morphologyAndFeatures: '',
        name: '',
        habits: '',
        species: '',
        imageUrl: '',
        soundUrl: '',
        description: '',
        growthAndDistribution: ''
    })

    //setter
    const setId = (id) => {
        bird.value.id = id
    }
    const setCreatedAt = (createdAt) => {
        bird.value.createdAt = createdAt
    }
    const setUpdatedAt = (updatedAt) => {
        bird.value.updatedAt = updatedAt
    }
    const setMorphologyAndFeatures = (morphologyAndFeatures) => {
        bird.value.morphologyAndFeatures = morphologyAndFeatures
    }
    const setName = (name) => {
        bird.value.name = name
    }
    const setHabits = (habits) => {
        bird.value.habits = habits
    }
    const setSpecies = (species) => {
        bird.value.species = species
    }
    const setImageUrl = (imageUrl) => {
        bird.value.imageUrl = imageUrl
    }
    const setSoundUrl = (soundUrl) => {
        bird.value.soundUrl = soundUrl
    }
    const setDescription = (description) => {
        bird.value.description = description
    }
    const setGrowthAndDistribution = (growthAndDistribution) => {
        bird.value.growthAndDistribution = growthAndDistribution
    }
    const setBird = (newBird) => {
        bird.value = newBird;
    };

    
    return { 
        bird,
        setId, 
        setCreatedAt, 
        setUpdatedAt, 
        setMorphologyAndFeatures, 
        setName, 
        setHabits, 
        setSpecies, 
        setImageUrl, 
        setSoundUrl, 
        setDescription, 
        setGrowthAndDistribution,
    }

},
{
    persist: true//持久化存储
}
); 